<?php
declare(strict_types=1);
namespace App\Dao;

use App\Model\RechargeAmountChannel;
use App\Model\ChannelArea;

class RechargeAmountChannelDao
{

    use DaoTrait;

    public function __construct()
    {
        $this->driver = __CLASS__;
    }

    /**
     * 新建渠道地区
     * @param $insertArray
     * @return int
     */
    public function add($insertArray){
        return RechargeAmountChannel::query()->insertGetId($insertArray);

    }


    /**
     * 查询
     * @param $where
     * @param string[] $columns
     * @return array
     */
    public function searchByWhere($where, $columns=['*']){
        return RechargeAmountChannel::query()->where($where)->get($columns)->toArray();
    }

    /**
     * 更新
     * @param $where
     * @param $updateArray
     * @return int
     */
    public function update($where, $updateArray){
        return RechargeAmountChannel::query()->where($where)->update($updateArray);
    }


    /**
     * 查询
     * @param $where
     * @return \Hyperf\Utils\HigherOrderTapProxy|mixed|void|null
     */
    public function costByWhere($where){
        return RechargeAmountChannel::query()->where($where)->value('cost');
    }

}